package rise.ui;

import rise.net.ServerConnection;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

public class Settings extends RiseActivity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_settings);
		
		EditText serverIpField = (EditText)this.findViewById(R.id.settingsServerIP);
		String serverIp = ServerConnection.getAddress();
		serverIpField.setHint(serverIp);
		serverIpField.setText(serverIp);
	}
	
	/*public void cancel(View v){
		this.finish();
	}*/
	public void submit(View v){
		EditText serverIpField = (EditText)this.findViewById(R.id.settingsServerIP);
		String serverIp = serverIpField.getText().toString();
		ServerConnection.setServerAddress(serverIp);
		
		Toast toast = Toast.makeText(this,
				"Impostazioni salvate",
				Toast.LENGTH_SHORT);
		toast.show();
		//this.finish();
	}
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		super.onCreateOptionsMenu(menu);
		menu.findItem(R.id.menu_settings).setVisible(false);
		return true;
	}
}
